
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>网盘</title>

    <!-- Bootstrap core CSS -->
    <link href="./Tpl/css/bootstrap.min.css" rel="stylesheet">
    <style type="text/css">
      body {
        padding-top: 50px;
      }
      .starter-template {
        padding: 40px 15px;
        text-align: center;
      }
      .table>tbody>tr>td {
        vertical-align: middle;
      }
      td img{
        height: 50px;
        width: 50px;
      }

    </style>
  </head>

  <body>

    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Project name</a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
            <li class="active"><a href="#">Home</a></li>
            <li><a href="#about">About</a></li>
            <li><a href="#contact">Contact</a></li>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </nav>

    <div class="container">

      <div class="starter-template">
         <form action="upload.php" method="post" enctype="multipart/form-data" style="padding-bottom:20px;height:50px;">
            <input type="submit" class="btn btn-default" style="display:inline-block;float:right;margin-left:20px;height:40px;">

            <input type="file" name="files[]" id="file" class="btn btn-default" style="display:inline-block;float:right;" multiple="multiple">
            
            
          </form>


          <table class="table table-hover" style="margin-top:20px;">
              <tr>
                <td>序号</td>
                <td>预览</td>
                <td>文件名</td>
                <td>文件大小</td>
                <td>上传时间</td>
                <td>下载</td>
                <td>删除</td>
              </tr>
              <?php foreach ($data as $key => $value) {?>
              <tr>
                <td><?php echo $key+1; ?></td>
                
                <td>
                <div style="height:40px;width:40px;display:inline-block;background-image:url('<?php
                    $arr = explode('.', $value['name']);
                    $suffix  = end($arr);
                    $imgType = ['jpg','png','gif'];
                    if(in_array($suffix, $imgType)){
                      echo "./disk/".$value['name'];
                     }else if($suffix=='zip'){
                      echo "./Tpl/img/zip.jpg";
                     }
                     ?>');background-repeat:no-repeat; background-size:100% 100%;"></div>
                  
                </td>
                <td><?php echo $value['name']; ?></td>
                <td><?php echo $value['size']; ?></td>
                <td><?php echo Ftime($value['time']); ?></td>
                <td><a class="btn btn-default" href="./download.php?id=<?php echo $key; ?>">下载</a></td>
                <td><a class="btn btn-default" href="./del.php?id=<?php echo $key; ?>">删除</a></td>
              </tr>
              <?php } ?>
            </table>

            <!-- 分页 -->
          <ul class="pagination" style="float:right;" >
            <!-- 上一页 -->
            <?php if($page>1){ ?>
            <li><a href="./index.php?page=<?php echo $page-1; ?>" aria-label="Previous"><span aria-hidden="true">«</span></a></li>
            <?php } ?>
            <!-- 页码 -->
            <?php 
            if ($page<=3) {
              $start=1;
            }else if($page>=$pages-2){
              $start=$pages-4;
            }else{
              $start=$page-2;
            }
            if ($page>=$pages-2) {
              $end=$pages;
            }elseif ($page<=3) {
              $end=5;
            }else{
              $end=$page+2;
            }

             ?>

            <?php for ($i=$start; $i<= $end; $i++){ ?> 
            <li class="<?php if($page==$i){echo "active";} ?>"><a href="./index.php?page=<?php echo $i; ?>"><?php echo $i; ?> <span class="sr-only">(current)</span></a></li>
           <?php } ?>
            <!-- 下一页 -->
            <?php if($page<$pages){ ?>
            <li><a href="./index.php?page=<?php echo $page+1; ?>" aria-label="Next"><span aria-hidden="true">»</span></a></li>
            <?php } ?>
         </ul>

      </div>

    </div><!-- /.container -->


    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
  </body>
</html>
